package org.carabiner.infinitest.swingui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;

import javax.swing.BorderFactory;
import javax.swing.JProgressBar;

public class CustomProgressBar extends JProgressBar
{
  public CustomProgressBar()
  {
    setBorder(BorderFactory.createLineBorder(getBackground(), 2));
    setBorderPainted(true);
  }
  
  @Override
  protected void paintComponent(Graphics g)
  {
    Graphics2D g2 = (Graphics2D) g.create();
    Rectangle rectangle = new Rectangle(0, 0, (int) (getPercentComplete() * getSize().getWidth()), getSize().height);
    g2.setColor(getForeground());
    g2.fill(rectangle);
    g2.setColor(Color.BLACK);
    g2.drawString(getString(), 10, 15);
    g2.dispose();
  }
}
